<template>
	<view style="padding:10px">
		<uni-forms ref="baseForm" label-width="75px">
			<uni-forms-item label="姓名">
				<uni-easyinput v-model="userInfo.RealName" placeholder="请输入姓名" />
			</uni-forms-item>
			<uni-forms-item label="手机号">
				<uni-easyinput v-model="userInfo.UserPhone" placeholder="请输入手机号" />
			</uni-forms-item>
			<uni-forms-item label="身份证号">
				<uni-easyinput v-model="userInfo.idCard" placeholder="请输入身份证号" />
			</uni-forms-item>
		</uni-forms>

		<button @click="realName" style="position: fixed;bottom: 40px;width: calc(100% - 20px);"
			type="primary">实名认证</button>
	</view>
</template>

<script>
	import {
		regPhone,
		regIdCard
	} from '../../utils/regExp.js'
	export default {
		data() {
			return {
				userInfo: {}
			}
		},
		onLoad() {
			this.userInfo = uni.getStorageSync('userInfo')
		},
		methods: {
			realName() {
				if (!this.userInfo.RealName || !this.userInfo.UserPhone || !this.userInfo.idCard) return this.$api.msg(
					'请完善实名信息')
				if (!regPhone.test(this.userInfo.UserPhone)) return this.$api.msg('请输入正确的手机号')
				if (!regIdCard.test(this.userInfo.idCard)) return this.$api.msg('请输入正确的身份证号')
				this.$verhttp('post', '/auth/VeriRecord/auth3', {
					"phone": this.userInfo.phone,
					"name": this.userInfo.name,
					"idNumber": this.userInfo.idCard,
					"state": true
				}).then(res => {
					console.log(res);
				})
			}
		}
	}
</script>

<style>

</style>